package com.cee.admin.modules.sys.controller;

import com.cee.common.web.result.Result;
import com.cee.domain.modules.sys.entity.SysConfCity;
import com.cee.domain.modules.sys.vo.SysConfCityVo;
import com.cee.ds.modules.sys.service.ISysConfCityService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.cee.admin.common.BaseController;

import java.util.List;

/**
 * <p>
 * 城市表 前端控制器
 * </p>
 *
 * @author hys
 * @since 2024-01-25
 */
@RestController
@RequestMapping("api/sys/config/city")
public class SysConfCityController extends BaseController {

    @Autowired
    private ISysConfCityService sysConfCityService;

    @GetMapping("/list")
    @Operation(summary = "根据省份id查找城市")
    public Result<List<SysConfCity>> list(@RequestParam Integer provinceId) {
        return success(sysConfCityService.lambdaQuery().eq(SysConfCity::getProvinceId, provinceId).list());
    }

    @GetMapping("/tree")
    @Operation(summary = "城市的树形结构", description = "第一级为省份，第二级为城市")
    public Result<List<SysConfCityVo>> tree() {
        return success(sysConfCityService.tree());
    }

}
